<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>教师管理-华信智原教师签课时系统</title>
<link rel="stylesheet" type="text/css" href="css/normalize.css">
<link rel="stylesheet" type="text/css" href="css/font/iconfont.css">
<link rel="stylesheet" type="text/css" href="css/base.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="js/kalendae/kalendae.css">
<link rel="stylesheet" type="text/css" href="css/newkalendae.css">
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/kalendae/kalendae.standalone.js"></script>
<script type="text/javascript" src="js/keshi.js"></script>

<!--包括IE9以及IE9以下的--> 
<!--[if lte IE 9]>
  <style>
  	.select-wrap:after{
    	display:none;}
    .keshi-form select{
    padding-right:1px;}
  </style>
<![endif]-->

</head>

<body>
<header>
    <div id="header-wrap">
        <div id="header" class="header-neiye">
            <h1>华信智原教师签课时系统v1.0</h1>
        </div>
    </div>
</header>
<main id="main-wrap">
	<div id="container" class="clearfix neiye">
    	<div id="admin-wrap" class="fl">
            <div id="admin-teacher-head" class="clearfix">
            	<div class="fr">
                    <span class="buttons" id="addTeacher">添加新老师</span>
                    <span class="buttons" id="viewAll">查看全部老师</span>
                </div>
                <!--添加新老师-->
                <div class="change-wrap record-bg hide">
                    <div class="addteacher-wrap  changeRecord" id="addnewteacher">
                    	<h3>添加新老师</h3>
                        <form name="addTeacher" method="post" action="">
               		<div class="teacher">
                    	<input type="text" name="name" placeholder="姓名" id="newTeacher" autocomplete="off">
                    </div>
                    <div class="error-tips">
                        <span class="error-message hide" id="newTeacher-name"></span></div>

                            <div class="teacher">
                                <input type="text" name="username" placeholder="账号" id="username" autocomplete="off">
                            </div>

                            <div class="error-tips">
                                <span class="error-message hide" id="username-name"></span></div>
                    <div class="teacher career">
                    	<div class="select-wrap">
                            <select name="couresid" id="career">
                            </select>
                        </div>
                    </div>
                    <div class="teacher">
                    	<input type="password" name="password" placeholder="输入新密码，6到12个字符或数字" id="newTeacherPwd1">
                    </div>
                    <div class="error-tips"><span class="error-message hide" id="newteacherpwd-message1">密码必须是6到12个字符或数字</span></div>
                    
                    <div class="teacher">
                    	<input type="password" name="teacherpwd" placeholder="确认新密码保持一致" id="newTeacherPwd2">
                    </div>
                	<div class="error-tips"><span class="error-message hide" id="newteacherpwd-message2">两个新密码不一致</span></div>
                    <div class="teacher">
                        <input type="button" value="点击确认添加" class="btn-submit off" id="btn-teacherSubmit">
                    </div>
                </form>
                		<i class="iconfont icon-close"></i>
                    </div>
                    
                </div>
            	<div id="searchTeacher" class="fr">
                    <form name="searchTeacher" method="post" action="">
                        <input type="text" placeholder="输入教师名字" id="teachername">
                        <button type="button" id="btn-teacher"><i class="iconfont icon-search"></i></button>
                    </form>
                </div>
                
            </div>
            <div id="teacher-list">
                <div class="group">
                    <h3>UI组</h3>
                    <ul class="clearfix">
                        <li>
                            <div class="touxiang"><a href="adminRecordList.html"><img src="images/touxiang/1.jpg"></a>
                            </div>
                            <div class="teachername"><a href="#">赵岚稹 <span class="hide">隐藏</span></a></div>
                        </li>

                    </ul>
                </div>
            </div>
        </div>
        <aside class="fr">
        	<div id="slidebar" class="fr">
                <div id="teacher-info">
                    <div id="touxiang">
                        <a href="#"><img src="images/touxiang.jpg" alt="管理员头像"></a></div>
                    <h1 class="center">汪帆</h1>
                </div>
                <nav id="teacher-menu">
                    <div id="menulist">
                        <ul>
                            <li><a href="adminIndex.html" class="active">教师信息管理</a></li>
                            <li><a href="adminSchool.html" >教务教学管理</a></li>
                            <li><a href="keshiCount.html" >课时统计管理</a></li>
                            <li><a href="adminInfo.html">管理员管理</a></li>
                             <li><a href="admindata.html">数据备份/恢复</a></li>
                              <li><a href="index.html">退出管理系统</a></li>
                        </ul>
                    </div>
                </nav>
            </div>
        </aside>
	</div>
</main>
<footer id="footer-wrap">
	<div id="footer">
    	<p>课时系统兼容IE9+、谷歌、火狐等现代浏览器，浏览器版本过低会影响用户体验</p>
        <a href="http://www.beian.miit.gov.cn/">蜀ICP备19040405号</a>
        <p>课时系统兼容IE8+，以及谷歌、火狐等现代浏览器</p>
        <p>设计+前端开发：赵岚稹
</p>
        <p>后端开发：宋连华</p>
    </div>
</footer>
<script>
$(function(){
	$('.icon-close').click(function(){
		$('.record-bg').addClass('hide');
		})

    $.post("user/userinfo", function (res) {
       if(res.flag){
           $("#touxiang a img").attr("src",res.data.facIcon);
           $("#teacher-info .center").html(res.data.name)

       }else{
           window.location.href = "/"
       }
    })
    //添加授课专业

    $.get("/coures/all", function (res) {

        var html = "";
        for (var i = 0; i < res.data.length; i++) {
            html += ' <option value="' + res.data[i].id + '">' + res.data[i].coursename + '</option>';
        }
        $("#career").append(html);


    })

    $("#btn-teacherSubmit").click(function () {

        var data = $("#addnewteacher form").serialize();
        console.log(data)
        $.post("/user/addnewteacher", data, function (res) {
          if(res.flag){
              $('.change-wrap').addClass("hide");
          }else{
              alert("添加失败")
          }
        })

    })
    $.post("/user/courseTeacherMapper", {}, function (res) {

        if (res.flag) {
            var teacher = $("#teacher-list");
            var html = "";
            for (var i = 0; i < res.data.length; i++) {

                if(res.data[i].user.length>0){
                html +="   <div class=\"group\">\n" +
                    "<h3>"+res.data[i].coursename+"</h3>  " +
                    "<ul class=\"clearfix\">\n"

               for (var j = 0; j < res.data[i].user.length; j++) {


                   html +="   <li>\n" +
                       "<div class=\"touxiang\"><a href=\"adminRecordList.html\"><img src=\""+ res.data[i].user[j].facIcon+" \"></a>\n" +
                       " </div>\n" +
                       " <div class=\"teachername\"><a href=\"#\">"+   res.data[i].user[j].name+" <span class=\"hide\">隐藏</span></a></div>\n" +
                       " </li>"


               }



                html += "</ul>" +
                    "</div>"
            }
            }
            console.log(html)
            teacher.append(html)
        }
    })



	})
</script>
</body>
</html>
